package com.example.basic;

public class Seckill implements Runnable{
    private Integer ticketNum=1500;
    private Boolean flag=true;
    @Override
    public void run() {
      while (flag){
              synchronized (this){
                  if(ticketNum<=0){
                      System.out.println("票卖完");
                     break;
                  }
                  System.out.println(Thread.currentThread().getName()+"强到第"+ticketNum--);
              }
      }
    }

    public synchronized void takingTicket(){
    }

    public static void main(String[] args) {
        Seckill seckill = new Seckill();
        Thread thread = new Thread(seckill,"小明");
        Thread thread2 = new Thread(seckill,"小白");
        Thread thread3 = new Thread(seckill,"小1");
        Thread thread4 = new Thread(seckill,"小2");
        Thread thread5 = new Thread(seckill,"小22");
        thread.start();
        thread2.start();
        thread3.start();
        thread4.start();
        thread5.start();
    }
}
